<template>
  <div>
    <div class="banner" @click="showGallary">
      <img class="banner-img"
          :src="bannerImg"
          alt="banner-image">
      <div class="banner-info">
        <div class="banner-title">{{sightName}}</div>
        <div class="banner-number">
          <i class="iconfont icon-tupian"></i>
          {{gallaryImgs.length}}
        </div>
      </div>
    </div>
    <FadeAnimation>
      <Gallary :imgs="gallaryImgs" v-if="gallaryShow" @hiddenGallary="hiddenGallary" />
    </FadeAnimation>
  </div>
</template>

<script>
import Gallary from '@/common/gallary/Gallary'
import FadeAnimation from '@/common/fade/FadeAnimation'
export default {
  props: {
    sightName: String,
    bannerImg: String,
    gallaryImgs: Array
  },
  components: {
    Gallary,
    FadeAnimation
  },
  data () {
    return {
      gallaryShow: false
    }
  },
  methods: {
    showGallary () {
      this.gallaryShow = true
      document.documentElement.style.overflow = 'hidden'
    },
    hiddenGallary () {
      this.gallaryShow = false
      document.body.scrollTop = 0
      document.documentElement.scrollTop = 0
    }
  },
  activated () {
    this.gallaryShow = false
  }
}
</script>

<style lang='stylus' rel='stylesheet/stylus' scoped>
  .banner
    position relative
    overflow hidden
    height 0
    padding-bottom 55%
    .banner-img
      width 100%
    .banner-info
      display flex
      position absolute
      bottom 0
      left 0
      right 0
      padding-right .2rem
      line-height .6rem
      color #fff
      background-image linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8))
      .banner-title
        flex 1
        padding-left .4rem
        font-size .32rem
      .banner-number
        margin-top .14rem
        padding 0 .4rem
        height .32rem
        line-height .32rem
        border-radius .2rem
        font-size .24rem
        background rgba(0, 0, 0, .5)
        .iconfont
          font-size .28rem
</style>
